import http from "@/api/config/http";
import { IQuery, IResponse, ITableResponse } from "@/types/http/IAxios";

// 查询商品字段列表
export function listField(query?: IQuery): Promise<ITableResponse<Field>> {
  return http.request({
    url: "/goods/field/list",
    method: "get",
    params: query
  });
}

export function queryField(query?: {
  fieldType: 1 | 0 | 2;
  status?: 0 | 1;
}): Promise<ITableResponse<Field>> {
  return http.request({
    url: "/goods/field/query",
    method: "get",
    params: query
  });
}
// 删除商品字段
export function delField(fieldId: Array<string>): Promise<IResponse<any>> {
  return http.request({
    url: `/goods/field/${fieldId}`,
    method: "delete"
  });
}

export function getField(fieldId: string): Promise<IResponse<any>> {
  return http.request({
    url: `/goods/field/${fieldId}`,
    method: "get"
  });
}

// 新增商品字段
export function addField(data: Field): Promise<IResponse<string>> {
  return http.request({
    url: "/goods/field",
    method: "post",
    data
  });
}
// 修改商品字段
export function updateField(data: Field) {
  return http.request({
    url: "/goods/field",
    method: "put",
    data
  });
}
